﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microhard.Permission.Interface;
using Microhard.Core.DBUtility;

namespace Microhard.Permission.MVCFilter
{
    public class ActionFilterFactory
    {

        public static IActionDataFilter GetActionFilter(string actionName, out bool isWorkflowAction)
        {
            isWorkflowAction = false;
            switch (actionName.ToLower())
            {
                case "index":
                    return new CommonActionFilter();
                case "create":
                    return new BeforeCreatePageFilter();
                case "savecreate":
                    return new BeforeCreateActionFilter();
                case "update":
                    return new BeforeUpdateActionFilter();
                case "updatebymodel":
                case "saveupdate":
                    return new BeforeSaveUpdateActionFilter();
                case "delete":
                    return new BeforeBatchDeleteActionFilter();
                case "deletesingle":
                    return new BeforeDeleteSingleModelActionFilter();
                case "_getsinglemodel":
                    return new BeforeGetSingleModelActionFilter();
            }
            return null;
        }

        public static IAfterActionDataFilter GetActionExecutedFilter(string actionName)
        {
            switch (actionName)
            {
                case "_listwithnopaging":
                case "_list":
                    return new AfterListActionFilter();
                case "index":
                    return new AfterIndexActionFilter();
                case "savecreate":
                    return new AfterSaveCreateActionFilter();
                case "delete":
                case "deletesingle":
                    return new AfterDeleteActionFilter();
            }
            return null;
        }
    }
}
